{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "af1dc7ff-56b2-4444-b272-766a556f3d9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2024-09-12 17:33:36--  http://mirror.coggle.club/yolo/Arial.ttf\n",
      "正在解析主机 mirror.coggle.club (mirror.coggle.club)... 218.12.116.57, 218.12.116.59, 218.12.116.56, ...\n",
      "正在连接 mirror.coggle.club (mirror.coggle.club)|218.12.116.57|:80... 已连接。\n",
      "已发出 HTTP 请求，正在等待回应... 200 OK\n",
      "长度： 773236 (755K) [font/ttf]\n",
      "正在保存至: ‘/home/lyz/.config/Ultralytics/Arial.ttf’\n",
      "\n",
      "/home/lyz/.config/U 100%[===================>] 755.11K  --.-KB/s    用时 0.1s    \n",
      "\n",
      "2024-09-12 17:33:36 (6.34 MB/s) - 已保存 ‘/home/lyz/.config/Ultralytics/Arial.ttf’ [773236/773236])\n",
      "\n",
      "--2024-09-12 17:33:36--  http://mirror.coggle.club/yolo/Arial.Unicode.ttf\n",
      "正在解析主机 mirror.coggle.club (mirror.coggle.club)... 218.12.116.58, 218.12.116.57, 218.12.116.60, ...\n",
      "正在连接 mirror.coggle.club (mirror.coggle.club)|218.12.116.58|:80... 已连接。\n",
      "已发出 HTTP 请求，正在等待回应... 200 OK\n",
      "长度： 23278008 (22M) [application/x-font-ttf]\n",
      "正在保存至: ‘/home/lyz/.config/Ultralytics/Arial.Unicode.ttf’\n",
      "\n",
      "/home/lyz/.config/U 100%[===================>]  22.20M  9.77MB/s    用时 2.3s    \n",
      "\n",
      "2024-09-12 17:33:39 (9.77 MB/s) - 已保存 ‘/home/lyz/.config/Ultralytics/Arial.Unicode.ttf’ [23278008/23278008])\n",
      "\n",
      "--2024-09-12 17:33:39--  http://mirror.coggle.club/yolo/yolov8n-v8.2.0.pt\n",
      "正在解析主机 mirror.coggle.club (mirror.coggle.club)... 218.12.116.57, 218.12.116.58, 218.12.116.60, ...\n",
      "正在连接 mirror.coggle.club (mirror.coggle.club)|218.12.116.57|:80... 已连接。\n",
      "已发出 HTTP 请求，正在等待回应... 200 OK\n",
      "长度： 6549796 (6.2M) [application/vnd.snesdev-page-table]\n",
      "正在保存至: ‘yolov8n.pt’\n",
      "\n",
      "yolov8n.pt          100%[===================>]   6.25M  9.17MB/s    用时 0.7s    \n",
      "\n",
      "2024-09-12 17:33:40 (9.17 MB/s) - 已保存 ‘yolov8n.pt’ [6549796/6549796])\n",
      "\n",
      "--2024-09-12 17:33:40--  http://mirror.coggle.club/yolo/yolov8m-v8.2.0.pt\n",
      "正在解析主机 mirror.coggle.club (mirror.coggle.club)... 218.12.116.58, 218.12.116.59, 218.12.116.56, ...\n",
      "正在连接 mirror.coggle.club (mirror.coggle.club)|218.12.116.58|:80... 已连接。\n",
      "已发出 HTTP 请求，正在等待回应... 200 OK\n",
      "长度： 52136884 (50M) [application/vnd.snesdev-page-table]\n",
      "正在保存至: ‘yolov8m.pt’\n",
      "\n",
      "yolov8m.pt          100%[===================>]  49.72M  9.79MB/s    用时 5.1s    \n",
      "\n",
      "2024-09-12 17:33:45 (9.70 MB/s) - 已保存 ‘yolov8m.pt’ [52136884/52136884])\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!mkdir -p ~/.config/Ultralytics/\n",
    "!wget http://mirror.coggle.club/yolo/Arial.ttf -O ~/.config/Ultralytics/Arial.ttf\n",
    "!wget http://mirror.coggle.club/yolo/Arial.Unicode.ttf -O ~/.config/Ultralytics/Arial.Unicode.ttf\n",
    "!wget http://mirror.coggle.club/yolo/yolov8n-v8.2.0.pt -O yolov8n.pt\n",
    "# !wget http://mirror.coggle.club/yolo/yolov8s-v8.2.0.pt -O yolov8s.pt\n",
    "!wget http://mirror.coggle.club/yolo/yolov8m-v8.2.0.pt -O yolov8m.pt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "523c892b-779d-4433-ac8e-c3baceacc291",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import glob\n",
    "import shutil\n",
    "\n",
    "os.makedirs('val', exist_ok=True)\n",
    "os.makedirs('val/labels', exist_ok=True)\n",
    "os.makedirs('val/images', exist_ok=True)\n",
    "\n",
    "labels = glob.glob('./train/labels/*')\n",
    "images = glob.glob('./train/images/*')\n",
    "\n",
    "labels.sort(); images.sort()\n",
    "\n",
    "for x, y in zip(labels[-50:], images[-50:]):\n",
    "    shutil.move(x, 'val/labels/')\n",
    "    shutil.move(y, 'val/images/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1e87748b-fcfc-4a1d-badb-89a1bf7f732c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "dir_path = os.path.abspath('./') + '/'\n",
    "\n",
    "# 需要按照你的修改path\n",
    "with open('yolo.yaml', 'w', encoding='utf-8') as up:\n",
    "    up.write(f'''\n",
    "path: {dir_path}/\n",
    "train: train/\n",
    "val: val/\n",
    "\n",
    "names:\n",
    "    0: tas\n",
    "''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "41bca67b-9e05-4ed6-a42c-41e1717dcc8e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "New https://pypi.org/project/ultralytics/8.2.92 available 😃 Update with 'pip install -U ultralytics'\n",
      "Ultralytics YOLOv8.2.78 🚀 Python-3.11.8 torch-2.2.2+cu121 CUDA:1 (NVIDIA GeForce GTX 1080 Ti, 11170MiB)\n",
      "\u001b[34m\u001b[1mengine/trainer: \u001b[0mtask=detect, mode=train, model=yolov8m.pt, data=./yolo.yaml, epochs=40, time=None, patience=100, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=1, workers=8, project=None, name=train5, exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect/train5\n",
      "Overriding model.yaml nc=80 with nc=1\n",
      "\n",
      "                   from  n    params  module                                       arguments                     \n",
      "  0                  -1  1      1392  ultralytics.nn.modules.conv.Conv             [3, 48, 3, 2]                 \n",
      "  1                  -1  1     41664  ultralytics.nn.modules.conv.Conv             [48, 96, 3, 2]                \n",
      "  2                  -1  2    111360  ultralytics.nn.modules.block.C2f             [96, 96, 2, True]             \n",
      "  3                  -1  1    166272  ultralytics.nn.modules.conv.Conv             [96, 192, 3, 2]               \n",
      "  4                  -1  4    813312  ultralytics.nn.modules.block.C2f             [192, 192, 4, True]           \n",
      "  5                  -1  1    664320  ultralytics.nn.modules.conv.Conv             [192, 384, 3, 2]              \n",
      "  6                  -1  4   3248640  ultralytics.nn.modules.block.C2f             [384, 384, 4, True]           \n",
      "  7                  -1  1   1991808  ultralytics.nn.modules.conv.Conv             [384, 576, 3, 2]              \n",
      "  8                  -1  2   3985920  ultralytics.nn.modules.block.C2f             [576, 576, 2, True]           \n",
      "  9                  -1  1    831168  ultralytics.nn.modules.block.SPPF            [576, 576, 5]                 \n",
      " 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          \n",
      " 11             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           \n",
      " 12                  -1  2   1993728  ultralytics.nn.modules.block.C2f             [960, 384, 2]                 \n",
      " 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          \n",
      " 14             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           \n",
      " 15                  -1  2    517632  ultralytics.nn.modules.block.C2f             [576, 192, 2]                 \n",
      " 16                  -1  1    332160  ultralytics.nn.modules.conv.Conv             [192, 192, 3, 2]              \n",
      " 17            [-1, 12]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           \n",
      " 18                  -1  2   1846272  ultralytics.nn.modules.block.C2f             [576, 384, 2]                 \n",
      " 19                  -1  1   1327872  ultralytics.nn.modules.conv.Conv             [384, 384, 3, 2]              \n",
      " 20             [-1, 9]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           \n",
      " 21                  -1  2   4207104  ultralytics.nn.modules.block.C2f             [960, 576, 2]                 \n",
      " 22        [15, 18, 21]  1   3776275  ultralytics.nn.modules.head.Detect           [1, [192, 384, 576]]          \n",
      "Model summary: 295 layers, 25,856,899 parameters, 25,856,883 gradients, 79.1 GFLOPs\n",
      "\n",
      "Transferred 469/475 items from pretrained weights\n",
      "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/detect/train5', view at http://localhost:6006/\n",
      "Freezing layer 'model.22.dfl.conv.weight'\n",
      "\u001b[34m\u001b[1mAMP: \u001b[0mrunning Automatic Mixed Precision (AMP) checks with YOLOv8n...\n",
      "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/train/labels.cache... 194 images, 19 backgrounds, 0 corrupt: 100%|██████████| 194/194 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "\u001b[34m\u001b[1mval: \u001b[0mScanning /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/val/labels.cache... 50 images, 23 backgrounds, 0 corrupt: 100%|██████████| 50/50 [00:00<?, ?it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Plotting labels to runs/detect/train5/labels.jpg... \n",
      "\u001b[34m\u001b[1moptimizer:\u001b[0m 'optimizer=auto' found, ignoring 'lr0=0.01' and 'momentum=0.937' and determining best 'optimizer', 'lr0' and 'momentum' automatically... \n",
      "\u001b[34m\u001b[1moptimizer:\u001b[0m AdamW(lr=0.002, momentum=0.9) with parameter groups 77 weight(decay=0.0), 84 weight(decay=0.0005), 83 bias(decay=0.0)\n",
      "\u001b[34m\u001b[1mTensorBoard: \u001b[0mmodel graph visualization added ✅\n",
      "Image sizes 640 train, 640 val\n",
      "Using 8 dataloader workers\n",
      "Logging results to \u001b[1mruns/detect/train5\u001b[0m\n",
      "Starting training for 40 epochs...\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       1/40      9.08G      3.898      4.987      2.298         11        640: 100%|██████████| 13/13 [00:08<00:00,  1.60it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.43it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150     0.0114       0.06    0.00249   0.000767\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       2/40       8.7G      2.606      2.612      1.572          7        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.69it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150     0.0306      0.367     0.0246    0.00853\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       3/40      8.79G      2.261      1.942      1.403         12        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.72it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.233      0.287      0.153     0.0596\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       4/40      8.68G      2.131      2.088      1.277         25        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.78it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.221       0.28      0.156     0.0713\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       5/40      8.58G      2.025      1.841      1.301         17        640: 100%|██████████| 13/13 [00:07<00:00,  1.65it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.87it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.219      0.213      0.124     0.0463\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       6/40      8.79G      2.041      1.629      1.259         47        640: 100%|██████████| 13/13 [00:07<00:00,  1.65it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.88it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150    0.00961        0.4    0.00634     0.0028\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       7/40      8.68G      2.014      1.604       1.29         16        640: 100%|██████████| 13/13 [00:07<00:00,  1.65it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.84it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150     0.0185      0.473     0.0134    0.00637\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       8/40      8.79G      2.036      1.467      1.266         55        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.107      0.607     0.0841     0.0343\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "       9/40      8.68G      2.055      1.522      1.303        125        640: 100%|██████████| 13/13 [00:07<00:00,  1.65it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.83it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150     0.0409      0.553     0.0324     0.0142\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      10/40       8.8G      1.999      1.316      1.263         25        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.90it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.736        0.4      0.476      0.212\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      11/40      8.78G      2.019      1.344      1.287         32        640: 100%|██████████| 13/13 [00:07<00:00,  1.65it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.76it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.711      0.426      0.501      0.245\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      12/40      8.54G      1.948      1.412      1.249         16        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.71it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.349      0.307      0.231      0.103\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      13/40      8.41G      2.002      1.413      1.228         14        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.78it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.438      0.364      0.334      0.137\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      14/40      8.78G      1.893      1.343      1.205         23        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.75it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.219      0.307      0.168     0.0886\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      15/40       8.7G      1.842      1.287      1.176         14        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.85it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150       0.71      0.387      0.489      0.249\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      16/40      8.77G      1.801      1.197      1.186         21        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.88it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.536      0.393       0.39      0.207\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      17/40      8.67G      1.764      1.189      1.163         49        640: 100%|██████████| 13/13 [00:07<00:00,  1.64it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.67it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.526      0.353      0.382      0.195\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      18/40       8.8G      1.729       1.14      1.168         31        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.81it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.609       0.44      0.465      0.232\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      19/40      8.78G      1.828      1.336      1.206        118        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.89it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.653      0.564      0.571      0.271\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      20/40      8.49G      1.804      1.332      1.152         10        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.66it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.638       0.36      0.455      0.224\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      21/40      8.42G      1.696      1.143      1.147         14        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.80it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.698        0.4      0.512      0.281\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      22/40       8.8G      1.623      1.098      1.122         10        640: 100%|██████████| 13/13 [00:07<00:00,  1.63it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.88it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.622      0.467      0.508      0.209\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      23/40      8.78G       1.69      1.056      1.086         23        640: 100%|██████████| 13/13 [00:08<00:00,  1.62it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.82it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.784      0.487      0.546      0.322\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      24/40      8.49G      1.718      1.079      1.159         15        640: 100%|██████████| 13/13 [00:08<00:00,  1.62it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.87it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.767      0.473       0.57      0.272\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      25/40      8.67G      1.649      1.091      1.125          8        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.705      0.493      0.597      0.309\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      26/40       8.8G      1.678      1.092      1.181         10        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.83it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150       0.77      0.513      0.609      0.303\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      27/40      8.79G      1.568     0.9527      1.083         19        640: 100%|██████████| 13/13 [00:08<00:00,  1.62it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.809      0.553      0.628      0.346\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      28/40      8.98G      1.521     0.9147      1.067         15        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.89it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.774      0.493      0.551      0.292\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      29/40      8.68G      1.515     0.8876      1.067         15        640: 100%|██████████| 13/13 [00:08<00:00,  1.59it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.84it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.658       0.55      0.572      0.283\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      30/40      8.81G      1.584     0.9252      1.078         26        640: 100%|██████████| 13/13 [00:08<00:00,  1.60it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.87it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.766       0.52      0.569      0.282\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Closing dataloader mosaic\n",
      "\u001b[34m\u001b[1malbumentations: \u001b[0mBlur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      31/40      8.78G      1.541      1.104      1.106         12        640: 100%|██████████| 13/13 [00:09<00:00,  1.44it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.85it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.806      0.499      0.534      0.305\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      32/40      8.79G      1.444     0.9335      1.068          8        640: 100%|██████████| 13/13 [00:08<00:00,  1.59it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.785      0.535      0.616      0.304\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      33/40      8.68G       1.46     0.8578        1.1         19        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.86it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.789      0.493      0.597      0.297\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      34/40      8.79G      1.436     0.8926      1.083         19        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.85it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.838        0.5      0.592      0.324\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      35/40      8.99G      1.391      0.892      1.062          6        640: 100%|██████████| 13/13 [00:08<00:00,  1.60it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.74it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.868      0.533      0.625      0.323\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      36/40      8.77G      1.377     0.8193      1.034         18        640: 100%|██████████| 13/13 [00:08<00:00,  1.56it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.83it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.888      0.573      0.654      0.363\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      37/40      8.68G      1.429     0.9104      1.054          2        640: 100%|██████████| 13/13 [00:08<00:00,  1.58it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.87it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.818       0.56      0.626      0.327\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      38/40      8.79G      1.405     0.8564      1.052          7        640: 100%|██████████| 13/13 [00:08<00:00,  1.57it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.76it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.809      0.513      0.589       0.28\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      39/40      8.79G      1.359     0.7929      1.042          9        640: 100%|██████████| 13/13 [00:08<00:00,  1.58it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.72it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.791      0.527      0.588        0.3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "      40/40      8.78G      1.341     0.7934       1.05          7        640: 100%|██████████| 13/13 [00:08<00:00,  1.61it/s]\n",
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.88it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150      0.825      0.536      0.612      0.328\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "40 epochs completed in 0.152 hours.\n",
      "Optimizer stripped from runs/detect/train5/weights/last.pt, 52.0MB\n",
      "Optimizer stripped from runs/detect/train5/weights/best.pt, 52.0MB\n",
      "\n",
      "Validating runs/detect/train5/weights/best.pt...\n",
      "Ultralytics YOLOv8.2.78 🚀 Python-3.11.8 torch-2.2.2+cu121 CUDA:1 (NVIDIA GeForce GTX 1080 Ti, 11170MiB)\n",
      "Model summary (fused): 218 layers, 25,840,339 parameters, 0 gradients, 78.7 GFLOPs\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 2/2 [00:00<00:00,  3.46it/s]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   all         50        150       0.87      0.573      0.655      0.363\n",
      "Speed: 0.1ms preprocess, 9.5ms inference, 0.0ms loss, 0.5ms postprocess per image\n",
      "Results saved to \u001b[1mruns/detect/train5\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"1\"\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "\n",
    "from ultralytics import YOLO\n",
    "model = YOLO(\"yolov8m.pt\")\n",
    "results = model.train(data=\"./yolo.yaml\", epochs=40, device=1, batch=16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "e9dde939-3941-4438-a795-54f7ebd38fbe",
   "metadata": {},
   "outputs": [],
   "source": [
    "model = YOLO(\"runs/detect/train5/weights/best.pt\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "60a91e70-9491-4b02-9c64-859535027584",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0020.jpg: 448x640 15 tass, 11.6ms\n",
      "Speed: 3.9ms preprocess, 11.6ms inference, 1.2ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0076.jpg: 448x640 14 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0003.jpg: 448x640 19 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0060.jpg: 448x640 5 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0088.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0024.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0073.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0072.jpg: 448x640 7 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0093.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0007.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0081.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0042.jpg: 448x640 7 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0057.jpg: 448x640 6 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0008.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0029.jpg: 448x640 3 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0071.jpg: 448x640 9 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0100.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0075.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0025.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0022.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0032.jpg: 448x640 (no detections), 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0027.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0052.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0026.jpg: 448x640 5 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0049.jpg: 448x640 8 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0051.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0038.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0031.jpg: 448x640 5 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0062.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0033.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0070.jpg: 448x640 6 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0011.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0006.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0041.jpg: 448x640 12 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0096.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0099.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0079.jpg: 448x640 8 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0056.jpg: 448x640 7 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0097.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0009.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0005.jpg: 448x640 (no detections), 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0044.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0015.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0050.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0035.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0019.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0055.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0017.jpg: 448x640 6 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0013.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0047.jpg: 448x640 5 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0002.jpg: 448x640 6 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0014.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0010.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0068.jpg: 448x640 11 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0004.jpg: 448x640 5 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0080.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0018.jpg: 448x640 13 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0028.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0095.jpg: 448x640 1 tas, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0059.jpg: 448x640 8 tass, 10.6ms\n",
      "Speed: 2.1ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0085.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0037.jpg: 448x640 1 tas, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0040.jpg: 448x640 2 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0034.jpg: 448x640 7 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0065.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0039.jpg: 448x640 6 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0078.jpg: 448x640 9 tass, 10.6ms\n",
      "Speed: 2.0ms preprocess, 10.6ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0045.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0090.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0089.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0064.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0023.jpg: 448x640 15 tass, 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0087.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.0ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0074.jpg: 448x640 10 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0021.jpg: 448x640 5 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0063.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0098.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0067.jpg: 448x640 10 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0012.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0066.jpg: 448x640 8 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0091.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0084.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0069.jpg: 448x640 7 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0053.jpg: 448x640 11 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0077.jpg: 448x640 6 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0036.jpg: 448x640 1 tas, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0058.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0094.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0043.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0048.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0001.jpg: 448x640 36 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0083.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0054.jpg: 448x640 10 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0092.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0030.jpg: 448x640 2 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 0.9ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0086.jpg: 448x640 (no detections), 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 0.4ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0082.jpg: 448x640 29 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0046.jpg: 448x640 10 tass, 10.7ms\n",
      "Speed: 2.2ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0016.jpg: 448x640 12 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n",
      "\n",
      "image 1/1 /home/lyz/Work/Kaggle/科大讯飞2024/玉米雄穗识别挑战赛/test/image_0061.jpg: 448x640 4 tass, 10.7ms\n",
      "Speed: 2.1ms preprocess, 10.7ms inference, 1.0ms postprocess per image at shape (1, 3, 448, 640)\n"
     ]
    }
   ],
   "source": [
    "os.makedirs('submit', exist_ok=True)\n",
    "test_paths = glob.glob('test/*')\n",
    "\n",
    "for path in test_paths:\n",
    "    predictions = model(path, save_txt=None)\n",
    "    with open(\"./submit/\" + path.split('/')[-1][:-4] + '.txt', '+w') as file:\n",
    "          for idx, prediction in enumerate(predictions[0].boxes.xywhn): # change final attribute to desired box format\n",
    "              cls = int(predictions[0].boxes.cls[idx].item())\n",
    "              # Write line to file in YOLO label format : cls x y w h\n",
    "              file.write(f\"{cls} {prediction[0].item()} {prediction[1].item()} {prediction[2].item()} {prediction[3].item()}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "357e9662-7141-478f-afe3-d5f65511867c",
   "metadata": {},
   "outputs": [],
   "source": [
    "!zip -r submit.zip submit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0ca71770-83ca-4d4f-adfa-28ae7e0f64ba",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py3.11",
   "language": "python",
   "name": "py3.11"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
